package com.ask.mapper;

import com.ask.dto.GoodsSalesDTO;
import com.ask.dto.OrdersPageQueryDTO;
import com.ask.entity.Dish;
import com.ask.entity.Orders;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper  {
    void myInsert(Orders orders);

    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);

    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    void update(Orders orders);

    @Select("select count(*) from orders where status = #{status}")
    Integer getCountByStatus(Integer status);


    @Select("select * from orders where status = #{status} and order_time < #{orderTime} ")
    List<Orders> getByStatusAndOrderTime(LocalDateTime orderTime, Integer status);

    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    Double sumByMap(Map map);

    Integer countByMap(Map map);

    List<GoodsSalesDTO> getSalesTop10(LocalDateTime beginTime, LocalDateTime endTime);


    void updateCanceledOrder(Orders order);

    void insertBatch(List<Orders> ordersList);

    @Delete("delete from orders where user_id = #{userId}")
    void deleteByUserId(Long userId);


    List<Orders> list(Orders orders);

    List<Long> listDishIdsByUserId(Long userId);
}
